package com.guojiang.guopicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.guojiang.guopicturebackend.api.aliyunai.model.CreateOutPaintingTaskResponse;
import com.guojiang.guopicturebackend.model.dto.picture.*;
import com.guojiang.guopicturebackend.model.entity.Picture;
import com.guojiang.guopicturebackend.model.entity.User;
import com.guojiang.guopicturebackend.model.vo.picture.PictureVO;
import io.swagger.models.auth.In;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 过江辉
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-01-08 21:13:55
 */
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     *
     * @param inputSource          文件输入源
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource, PictureUploadRequest pictureUploadRequest, User loginUser);


    /**
     * 获取图片查询对象
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取图片封装类视图
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 分页获取图片封装类视图
     *
     * @param picturePage
     * @param request
     * @return 图片封装类视图分页列表
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 校验图片合法性
     *
     * @param picture
     */
    void validPicture(Picture picture);

    /**
     * 图片审核
     *
     * @param pictureReviewRequest
     * @param loginUser
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 在上传、更新、编辑图片以后填充审核相关参数
     *
     * @param picture
     * @param loginUser
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取和创建图片（管理员使用）
     *
     * @param pictureUploadByBatchRequest
     * @param loginUser
     * @return 批量抓取的图片数
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 清理对象存储图片文件
     *
     * @param picture
     * @return
     */
    void clearCosPictureFile(Picture picture);

    /**
     * 删除图片
     *
     * @param pictureId
     * @param loginUser
     * @return
     */
    boolean deletePicture(long pictureId, User loginUser);

    /**
     * 编辑图片（公共图库：图片创建者/管理员；非公共图库：图库管理者）
     *
     * @param pictureEditRequest
     * @param loginUser
     * @return
     */
    boolean editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 校验用户是否有修改空间图片的权限
     *
     * @param picture
     * @param loginUser
     */
    void checkPictureAuth(Picture picture, User loginUser);

    /**
     * 主色调搜索相似图片
     *
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 主色调搜索相似图片（管理员使用）
     *
     * @param spaceId
     * @param picColor
     * @param loginUser
     * @return
     */
    List<Picture> searchPictureForAdminByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     *
     * @param pictureEditByBatchRequest
     * @param loginUser
     */
    void editPictureByBatch(PictureEditByBatchRequest pictureEditByBatchRequest, User loginUser);

    /**
     * 创建扩图任务
     *
     * @param createPictureOutPaintingTaskRequest
     * @param loginUser
     * @return
     */
    CreateOutPaintingTaskResponse createPictureOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
